﻿Imports System.Data.SqlClient
Public Class clsPrecios
    Private mintIdRuta As Integer
    Private mdblPrecio As Double
    Private mstrAbre As String
    Public Property IdRuta() As Integer
        Get
            Return mintIdRuta
        End Get
        Set(ByVal value As Integer)
            mintIdRuta = value
        End Set
    End Property
    Public Property Precio() As Double
        Get
            Return mdblPrecio
        End Get
        Set(ByVal value As Double)
            mdblPrecio = value
        End Set
    End Property
    Public Property Abre() As String
        Get
            Return mstrAbre
        End Get
        Set(value As String)
            mstrAbre = value
        End Set
    End Property
    
    Public Sub New()
        mintIdRuta = 0
        mdblPrecio = 0
        mstrAbre = ""
    End Sub
     Public Sub Insertar()
        Dim sql As String = "Insert Into PrecioVueltas (" & _
                            "IdRuta," & _
                            "Precio," & _
                            "Abre)" & _
                            "VALUES (" & _
                            "@IdRuta," & _
                            "@Precio," & _
                            "@Abre)"



        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdRuta", mintIdRuta)
        Command.Parameters.AddWithValue("Precio", mdblPrecio)
        Command.Parameters.AddWithValue("Abre", mstrAbre)

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub

End Class
